/**
 * @param {number} x
 * @return {number}
 */
 var mySqrt = function(x) {
  // 也是二分法解题,首先判断中间的平方
  // 中间的大于target 就mid = 
  let left = 0
  let right = Math.floor(x / 2)
  while(left <= right){
    let mid = left + Math.floor((right - left) / 2)
    if(mid * mid > x){
      right = mid - 1
    }else if(mid * mid < x){
      left = mid + 1
    }else{
      return mid
    }
  }
  return right
};